home *** CD-ROM | disk | FTP | other *** search
- package components
- {
- import flash.events.SecurityErrorEvent;
- import flash.filesystem.File;
- import flash.filesystem.FileMode;
- import flash.filesystem.FileStream;
- import flash.utils.ByteArray;
- import mx.controls.Image;
- import mx.events.PropertyChangeEvent;
-
- public class ExtendedImage extends Image
- {
- private var _sourceFilePath:String;
-
- public function ExtendedImage()
- {
- super();
- this.addEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onSecurityError);
- }
-
- override protected function commitProperties() : void
- {
- var fs:FileStream = null;
- var f:File = null;
- var bytes:ByteArray = null;
- if(this._sourceFilePath)
- {
- try
- {
- f = new File(this._sourceFilePath);
- fs = new FileStream();
- fs.open(f,FileMode.READ);
- bytes = new ByteArray();
- fs.readBytes(bytes,0,fs.bytesAvailable);
- source = bytes;
- }
- catch(e:Error)
- {
- source = getStyle("brokenImageSkin");
- }
- finally
- {
- if(fs)
- {
- fs.close();
- }
- }
- }
- super.commitProperties();
- }
-
- [Bindable(event="propertyChange")]
- public function set sourceFilePath(param1:String) : void
- {
- var _loc2_:Object = this.sourceFilePath;
- if(_loc2_ !== param1)
- {
- this._2099171076sourceFilePath = param1;
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"sourceFilePath",_loc2_,param1));
- }
- }
-
- private function onSecurityError(param1:SecurityErrorEvent) : void
- {
- trace("SecurityError: " + param1.errorID + " : ");
- }
-
- private function set _2099171076sourceFilePath(param1:String) : void
- {
- if(param1 == null && Boolean(this._sourceFilePath))
- {
- source = null;
- this._sourceFilePath = null;
- }
- else
- {
- this._sourceFilePath = param1;
- }
- invalidateProperties();
- }
-
- public function get sourceFilePath() : String
- {
- return this._sourceFilePath;
- }
- }
- }
-
-